package com.chen.pfm.entity;


import com.chen.pfm.utils.DateUtils;
import com.chen.pfm.utils.MyUtil;
import ohos.data.orm.OrmObject;
import ohos.data.orm.annotation.Column;
import ohos.data.orm.annotation.Entity;
import ohos.data.orm.annotation.PrimaryKey;
import ohos.data.rdb.ValuesBucket;

import java.util.Date;

@Entity(tableName = "statements")
public class Statements extends OrmObject {
    //报表id
    @PrimaryKey
    @Column(name = "sid", index = true)
    private String sid;
    //用户id
    @Column(name = "uid", index = true)
    private int uid = -1;
    //预算
    private double budget = 0.0;

    //报表日期
    @Column(name = "sdate", index = true)
    private String sdate;
    //创建时间
    private String sctime;

    public Statements() {
    }

    @Override
    public String toString() {
        return "Statements{" +
                "sid='" + sid + '\'' +
                ", uid=" + uid +
                ", budget=" + budget +
                ", sdate='" + sdate + '\'' +
                ", sctime='" + sctime + '\'' +
                '}';
    }

    public Statements(int uid) {
        this.sid = MyUtil.randomUUID();
        this.uid = uid;
        this.budget = 0.0;
        this.sdate = DateUtils.getStrCurrentYearandMonth();
        this.sctime = DateUtils.getStrTimeFromDateTime(new Date());

    }

    public Statements(int uid, double budget) {
        this.sid = MyUtil.randomUUID();
        this.uid = uid;
        this.budget = budget;
        this.sdate = DateUtils.getStrCurrentYearandMonth();
        this.sctime = DateUtils.getStrTimeFromDateTime(new Date());

    }

    public Statements(String sid, int uid, double budget, String sdate, String sctime) {
        this.sid = sid;
        this.uid = uid;
        this.budget = budget;
        this.sdate = sdate;
        this.sctime = sctime;
    }

    public String getSid() {
        return sid;
    }

    public void setSid(String sid) {
        this.sid = sid;
    }
    public int getUid() {
        return uid;
    }

    public void setUid(int uid) {
        this.uid = uid;
    }

    public double getBudget() {
        return budget;
    }

    public void setBudget(double budget) {
        this.budget = budget;
    }


    public String getSdate() {
        return sdate;
    }

    public void setSdate(String sdate) {
        this.sdate = sdate;
    }

    public String getSctime() {
        return sctime;
    }

    public void setSctime(String sctime) {
        this.sctime = sctime;
    }

    public Statements getObjectfromValues(ValuesBucket valuesBucket) {

        this.sid = valuesBucket.getString("sid");
        this.uid = valuesBucket.getInteger("uid");
        this.budget = valuesBucket.getDouble("budget");
        this.sdate = valuesBucket.getString("sdate");
        this.sctime = valuesBucket.getString("sctime");
        return this;
    }

    public ValuesBucket getValuesBucketfromObject() {
        ValuesBucket valuesBucket = new ValuesBucket();
        valuesBucket.putString("sid", sid);
        valuesBucket.putInteger("uid", uid);
        valuesBucket.putDouble("budget", budget);
        valuesBucket.putString("sdate", sdate);
        valuesBucket.putString("sctime", sctime);
        return valuesBucket;
    }

}
